﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMD.DataModel.Entity
{
/** 
 * <p>类说明: 病人</p>
 * @version 1.0
 * <p>文件名： </p>
 * <p>创建人及时间： xiangyuliang 2011-8-27</p>
 * <p>修改人：</p>
 * <p>修改时间：</p>
 * <p>修改描述：</p>
 **/

    public class PatientInfo : BusinessEntity
    {
        //病人基本信息
        //public string id { get; set; }   //标识
        private string _clinicNo;  //门诊号
        private string _hospitalNo; //住院号
        private string _followUpNo; //随访号
        //private string _bedNo;  //床号
        //private string _name;   //姓名
        private string _sex;    //性别
        private int _age;    //年龄
        private string _area; //地域
        private DateTime _birthday;  //出生日期
        //临床治疗信息
        private DateTime _firstFollowUpTime;//首次随访时间
        private int _firstFollowUps; //随访周次
        private string _telephone; //联系电话
        private string _telephone2; 
        private string _address; //联系地址      
        private string _email;
        private string _pathologyNo; //病理号
        private double _height; //身高
        private double _weight; //体重

        public override void setValue(string key, Object value)
        {
            if (value is System.DBNull)
                return;
            switch (key.ToLower())
            {
                case "firstfollowup":
                    this.FirstFollowUpTime = (DateTime)value;
                    break;          
                case "telephone":
                    this.Telephone = (string)value;
                    break;
                case "telephone2":
                    this.Telephone2 = (string)value;
                    break;
                case "address":
                    this.Address = (string)value;
                    break;
                case "email":
                    this.Email = (string)value;
                    break;
                case "patientid":
                    this.Id = (string)value;
                    break;
                case "clinicno":
                    this.ClinicNo = (string)value;
                    break;
                case "followupno":
                    this.FollowUpNo = value.ToString();
                    break;
                case "pathologyno":
                    this.PathologyNo = value.ToString();
                    break;
                case "hospitalno":
                    this.HospitalNo = (string)value;
                    break;
                case "name":
                    this.Name = (string)value;
                    break;
                case "sex":
                    this.Sex = (string)value;
                    break;
                case "age":
                    this.Age = int.Parse(value.ToString());
                    break;
                case "area":
                    this.Area = value.ToString();
                    break;
                case "birthday":
                    this.Birthday = DateTime.Parse( value.ToString());
                    this.Age = GetAgeByBirthday(this.Birthday);
                    break;
                case "height":
                    this.Height = double.Parse(value.ToString());
                    break;
                case "weight":
                    this.Weight = double.Parse(value.ToString());
                    break;       
                default:
                    break;
            }
        }
        private int GetAgeByBirthday(DateTime date)
        {
            DateTime dateNow = System.DateTime.Now;
            int age = dateNow.Year - date.Year + 1;
            return age;
        }

        public double Height
        {
            get
            {
                return _height;
            }
            set
            {
                _height = value;
                OnPropertyChanged(() => Height);
            }
        }
        public double Weight
        {
            get
            {
                return _weight;
            }
            set
            {
                _weight = value;
                OnPropertyChanged(() => Weight);
            }
        }
        public int Age
        {
            get
            {
                return _age;
            }
            set
            {
                _age = value;
                OnPropertyChanged(() => Age);
            }
        }

         public string FollowUpNo
         {
            get
            {
                return _followUpNo;
            }
            set
            {
                _followUpNo = value;
                OnPropertyChanged(() => FollowUpNo);
            }
        }

        public string Area
        {
            get
            {
                return _area;
            }
            set
            {
                _area = value;
                OnPropertyChanged(() => Area);
            }
        }
        public string Address
        {
            get
            {
                return _address;
            }
            set
            {
                _address = value;
                OnPropertyChanged(() => Address);
            }
        }


        public string PathologyNo
        {
            get
            {
                return _pathologyNo;
            }
            set
            {
                _pathologyNo = value;
                OnPropertyChanged(() => PathologyNo);
            }
        }
        public string Email
        {
            get
            {
                return _email;
            }
            set
            {
                _email = value;
                OnPropertyChanged(() => Email);
            }
        }

        public string Telephone
        {
            get
            {
                return _telephone;
            }
            set
            {
                _telephone = value;
                OnPropertyChanged(() => Telephone);
            }
        }

        public string Telephone2
        {
            get
            {
                return _telephone2;
            }
            set
            {
                _telephone2 = value;
                OnPropertyChanged(() => Telephone2);
            }
        }

        public int FirstFollowUps
        {
            get
            {
                return _firstFollowUps;
            }
            set
            {
                _firstFollowUps = value;
                OnPropertyChanged(() => FirstFollowUps);
            }
        }
        
        public DateTime FirstFollowUpTime
        {
            get
            {
                return _firstFollowUpTime;
            }
            set
            {
                _firstFollowUpTime = value;
                OnPropertyChanged(() => FirstFollowUpTime);
            }
        }
      
        public String ClinicNo
        {
            get
            {
                return _clinicNo;
            }
            set
            {
                _clinicNo = value;
                OnPropertyChanged(() => ClinicNo);
            }
        }
        public String HospitalNo
        {
            get
            {
                return _hospitalNo;
            }
            set
            {
                _hospitalNo = value;
                OnPropertyChanged(() => HospitalNo);
            }
        }
      
        public String Sex
        {
            get
            {
                return _sex;
            }
            set
            {
                _sex = value;
                OnPropertyChanged(() => Sex);
            }
        }
        [CheckValue("病人信息“出生年月”不能为空")]
        public DateTime Birthday
        {
            get
            {
                return _birthday;
            }
            set
            {
                _birthday = value;
                OnPropertyChanged(() => Birthday);
            }
        }
  
    }
}
